﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ShredTheLog.Api.DataContracts;
using System.Windows.Threading;
using System.Windows;
using System.Collections.ObjectModel;
using System.Diagnostics.Contracts;

namespace ShredTheLog.Api
{
    [ContractClass(typeof(ShredServices_Contract))]
    public interface IShredServices : IDisposable
    {
        void Run();
        
        ITextChat TextChat { get; }

        void OpenTextChatRoom(string roomName);

        ReadOnlyObservableCollection<IContact> Contacts { get; }
        ReadOnlyObservableCollection<IShortUserInfo> TextChatUsers { get; }

        void ShowError(Exception ex);
        void ShowError(Func<string> message, Exception ex);
        void ShowError(Func<string> message, Func<string> details);
        void ShowMessage(Func<string> message);
        void ShowInfoBalloonTip(string title, string text);
        
        string GetLocalizedString(string key);

        void LoadSettings();
        void SaveSettings(bool raiseOnUpdated = true);
        event EventHandler SettingsUpdated;

        Dispatcher Dispatcher { get; }
        void Shutdown();
    }

    [ContractClassFor(typeof(IShredServices))]
    internal abstract class ShredServices_Contract : IShredServices
    {
        void IShredServices.Run()
        {
            throw new NotImplementedException();
        }

        ITextChat IShredServices.TextChat
        {
            get { throw new NotImplementedException(); }
        }

        void IShredServices.OpenTextChatRoom(string roomName)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(roomName));
        }

        ReadOnlyObservableCollection<IContact> IShredServices.Contacts
        {
            get
            {
                Contract.Ensures(Contract.Result<ReadOnlyObservableCollection<IContact>>() != null);
                throw new NotImplementedException();
            }
        }

        ReadOnlyObservableCollection<IShortUserInfo> IShredServices.TextChatUsers
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        void IShredServices.ShowError(Exception ex)
        {
            Contract.Requires(ex != null);
            throw new NotImplementedException();
        }

        void IShredServices.ShowError(Func<string> message, Exception ex)
        {
            Contract.Requires(message != null);
            Contract.Requires(ex != null);
            throw new NotImplementedException();
        }

        void IShredServices.ShowError(Func<string> message, Func<string> details)
        {
            Contract.Requires(message != null);
            Contract.Requires(details != null);
            throw new NotImplementedException();
        }

        void IShredServices.ShowMessage(Func<string> message)
        {
            Contract.Requires(message != null);
            throw new NotImplementedException();
        }

        void IShredServices.ShowInfoBalloonTip(string title, string text)
        {
            Contract.Requires(!String.IsNullOrEmpty(title));
            throw new NotImplementedException();
        }

        string IShredServices.GetLocalizedString(string key)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(key));
            Contract.Ensures(Contract.Result<string>() != null);
            throw new NotImplementedException();
        }

        void IShredServices.LoadSettings()
        {
            throw new NotImplementedException();
        }

        void IShredServices.SaveSettings(bool raiseOnUpdated)
        {
            throw new NotImplementedException();
        }

        event EventHandler IShredServices.SettingsUpdated
        {
            add { throw new NotImplementedException(); }
            remove { throw new NotImplementedException(); }
        }

        Dispatcher IShredServices.Dispatcher
        {
            get 
            {
                Contract.Ensures(Contract.Result<Dispatcher>() != null);
                throw new NotImplementedException(); 
            }
        }

        void IShredServices.Shutdown()
        {
            throw new NotImplementedException();
        }

        void IDisposable.Dispose()
        {
            throw new NotImplementedException();
        }
    }
}
